package org.liu.reactor;

import reactor.core.publisher.Flux;

import java.util.function.BinaryOperator;

public class reactor {
    public static void main(String[] args) {
        Flux<Integer> range = Flux.range(1, 7);
        range.toStream().reduce(new BinaryOperator<Integer>() {
                    @Override
                    public Integer apply(Integer integer, Integer integer2) {
//                        System.out.println(Thread.currentThread().getName() + ":" + integer);
                        return integer+ integer2;
                    }
                }).ifPresent(System.out::println);
        //调用了两次
        range.subscribe(integer -> System.out.println(Thread.currentThread().getName() + ":" + integer));
    }
}
